﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_UserMT : DLL.ShowLayer.BaseView
{
	private DLL.User.View clsUserView;
	/// <summary>
	/// 初始密码按钮
	/// </summary>
	private LinkButton lBtnInitPassword = new LinkButton();
	private DLL.User.Component clsUserComp;

	public Admin_UserMT()
		: base("idTotal")
	{
		clsUserView = new DLL.User.View(Page);

		clsView = clsUserView;
		
		lBtnInitPassword.Text = "初始密码";
		lBtnInitPassword.CommandName = "201410221642";
		lBtnInitPassword.ID = "201410221702";
		AddGridViewOperation(lBtnInitPassword);

		tfOperation.HeaderStyle.Width = 130;

		AddTableColumn(new TonyNet4V1.Structs.TableShowColumn("用户名", "Username"));
		AddTableColumn(new TonyNet4V1.Structs.TableShowColumn("用户组", "UserGroupName"));
		AddTableColumn(new TonyNet4V1.Structs.TableShowColumn("单位", "DepartmentName"));

		
	}

	protected void Page_Load(object sender, EventArgs e)
	{

	}

	protected override void OnInit(EventArgs e)
	{
		clsUserComp = new DLL.User.Component(Page);

		base.OnInit(e);

		gvTable.RowCommand += new GridViewCommandEventHandler(gvTable_RowCommand);
		gvTable.RowDataBound += new GridViewRowEventHandler(gvTable_RowDataBound);
	}

	void gvTable_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		if (e.Row.RowIndex >= 0)
		{
			//lBtnInitPassword.CommandArgument = ((GridView)sender).DataKeys[e.Row.RowIndex].Value.ToString();
			((LinkButton)e.Row.FindControl(lBtnInitPassword.ID)).CommandArgument = ((GridView)sender).DataKeys[e.Row.RowIndex].Value.ToString();
		}
	}

	void gvTable_RowCommand(object sender, GridViewCommandEventArgs e)
	{
		if (e.CommandName == lBtnInitPassword.CommandName)
		{
			if (clsUserComp.InitPassword(Convert.ToInt32(e.CommandArgument)))
			{
				TonyNet4V1.ShowMessageAlert.ShowMessage(Page, "初始化密码为：123456！");
				BindGridView();
			}
			
		}
	}

	
}